package zhuyun.code

fun main(args:Array<String>){
    val realSubject = RealSubject()
    val proxy = Proxy(realSubject)
    proxy.request()
}
interface Subject{
    fun request()
}
class RealSubject:Subject{
    override fun request() {
        println("访问真实主题方法")
    }

}
class Proxy(private val realSubject: RealSubject):Subject {

    override fun request() {
        preRequest()
        realSubject.request()
        postRequest()
    }
    fun preRequest(){
        println("访问真实主题之前的预处理")
    }
    fun postRequest(){
        println("访问真实主题之后的后续处理")
    }
}